package h.ku.eval
{
	public class WhileLoopEval extends AbstractLoopEval
	{
		public function WhileLoopEval(a:Array)
		{
			super("",a)
		}
		
		public override function doBreak():void
		{
			finishFunctionEval(null)
		}
		
		public override function doContinue():void
		{
			argIndex = 0
			beginArgEval()
		}
		
		protected override function finishArgEval(value:*):void
		{
			if(argIndex == 0){
				if(Boolean(value) == true)
				{
					argIndex = 1
					beginArgEval()
					//Condition is true, run the body.
				}else{
					finishFunctionEval(null)
					//Condition is false. Break.
				}
			}else{
				//Run the condition again!
				argIndex = 0
				beginArgEval()
			}
		}
	}
}